import http from './__http__'
import { getBaseURL } from '@/util/comman'
import { getUserApi } from './user'

export const gatewayApi = (data) => {
  return http.request({
    url: '/gateway',
    method: 'post',
    data
  })
}
export const addGatewayApi = (data) => {
  return http.request({
    url: '/gateway/add',
    method: 'post',
    data
  })
}
export const updateGatewayApi = (data) => {
  return http.request({
    url: '/gateway/update',
    method: 'post',
    data
  })
}
export const delGatewayApi = (data) => {
  return http.request({
    url: '/gateway/del',
    method: 'post',
    data
  })
}


export const chanelApi = (data) => {
  return http.request({
    url: '/chanel',
    method: 'post',
    data
  })
}
export const addChanelApi = (data) => {
  return http.request({
    url: '/chanel/add',
    method: 'post',
    data
  })
}
export const updateChanelApi = (data) => {
  return http.request({
    url: '/chanel/update',
    method: 'post',
    data
  })
}
export const delChanelApi = (data) => {
  return http.request({
    url: '/chanel/del',
    method: 'post',
    data
  })
}


export const deviceApi = (data) => {
  return http.request({
    url: '/device',
    method: 'post',
    data
  })
}
export const addDeviceApi = (data) => {
  return http.request({
    url: '/device/add',
    method: 'post',
    data
  })
}
export const updateDeviceApi = (data) => {
  return http.request({
    url: '/device/update',
    method: 'post',
    data
  })
}
export const delDeviceApi = (data) => {
  return http.request({
    url: '/device/del',
    method: 'post',
    data
  })
}


export const tagApi = (data) => {
  return http.request({
    url: '/tag',
    method: 'post',
    data
  })
}
export const addTagApi = (data) => {
  return http.request({
    url: '/tag/add',
    method: 'post',
    data
  })
}
export const updateTagApi = (data) => {
  return http.request({
    url: '/tag/update',
    method: 'post',
    data
  })
}
export const delTagApi = (data) => {
  return http.request({
    url: '/tag/del',
    method: 'post',
    data
  })
}


//导出网关配置
export const exportGwConfApi = (data) => {
  return http.request({
    url: '/gateway/export',
    method: 'post',
    data
  })
}


//重启网关
export const restartGatewayApi = () => {
  const baseURL = getBaseURL();
  return http.request({
    url: baseURL + '/GwConfig/RebootInfo',
    method: 'post',
    data: {
      cmd: 'reboot'
    }
  })
}


//恢复网关的出厂设置
export const resetGatewayApi = () => {
  const baseURL = getBaseURL();
  return http.request({
    url: baseURL + '/GwConfig/ResetInfo',
    method: 'post',
    data: {
      cmd: 'reset'
    }
  })
}




export const uploadToGatewayApi = (data) => {
  return http.request({
    url: '/gateway/upload',
    method: 'post',
    data
  })
}